import { request } from "../untils/request.js";
export default {
  login: async ({ username, password }) =>
    await request({
      type: "GET",
      data: { username, password },
      url: "/api/users/login",
    }),
  reg: async ({ username, password }) =>
    await request({
      type: "POST",
      data: { username, password },
      url: "/api/users/reg",
    }),
  setToken: (token) => (localStorage["_t"] = token),
  getToken: () => {
    localStorage["_t"];
  },
  //通过用户id查询用户的数据
  getOne: async (_id) =>
    await request({
      type: "GET",
      url: `/api/users/getone/${_id}`,
    }),
  //添加新订单
  //str座位名称 scheduleId排片Id,tatol总价,_id用户id
  addOrder: async ({ str, scheduleId, tatol, _id }) =>
    await request({
      type: "PATCH",
      data: { str, scheduleId, tatol, _id },
      url: `/api/users/order`,
    }),
  //获取所有用户
  getAllUsers: () =>
    request({
      type: "GET",
      url: `/api/users/getAllUsers`,
    }),
};
